# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=tcpdump
pkgver=4.99.5
pkgrel=0
pkgdesc="A tool for network monitoring and data acquisition"
url="https://www.tcpdump.org/"
arch="all"
license="BSD-3-Clause"
makedepends="cmake samurai libpcap-dev openssl-dev>3"
checkdepends="perl"
subpackages="$pkgname-doc"
source="https://www.tcpdump.org/release/tcpdump-$pkgver.tar.gz
	"

# secfixes:
#   4.9.3-r1:
#     - CVE-2020-8037
#   4.9.3-r0:
#     - CVE-2017-16808 # (AoE)
#     - CVE-2018-14468 # (FrameRelay)
#     - CVE-2018-14469 # (IKEv1)
#     - CVE-2018-14470 # (BABEL)
#     - CVE-2018-14466 # (AFS/RX)
#     - CVE-2018-14461 # (LDP)
#     - CVE-2018-14462 # (ICMP)
#     - CVE-2018-14465 # (RSVP)
#     - CVE-2018-14881 # (BGP)
#     - CVE-2018-14464 # (LMP)
#     - CVE-2018-14463 # (VRRP)
#     - CVE-2018-14467 # (BGP)
#     - CVE-2018-10103 # (SMB - partially fixed, but SMB printing disabled)
#     - CVE-2018-10105 # (SMB - too unreliably reproduced, SMB printing disabled)
#     - CVE-2018-14880 # (OSPF6)
#     - CVE-2018-16451 # (SMB)
#     - CVE-2018-14882 # (RPL)
#     - CVE-2018-16227 # (802.11)
#     - CVE-2018-16229 # (DCCP)
#     - CVE-2018-16301 # (was fixed in libpcap)
#     - CVE-2018-16230 # (BGP)
#     - CVE-2018-16452 # (SMB)
#     - CVE-2018-16300 # (BGP)
#     - CVE-2018-16228 # (HNCP)
#     - CVE-2019-15166 # (LMP)
#     - CVE-2019-15167 # (VRRP)
#     - CVE-2018-14879 # (tcpdump -V)
#   4.9.0-r0:
#     - CVE-2016-7922
#     - CVE-2016-7923
#     - CVE-2016-7924
#     - CVE-2016-7925
#     - CVE-2016-7926
#     - CVE-2016-7927
#     - CVE-2016-7928
#     - CVE-2016-7929
#     - CVE-2016-7930
#     - CVE-2016-7931
#     - CVE-2016-7932
#     - CVE-2016-7933
#     - CVE-2016-7934
#     - CVE-2016-7935
#     - CVE-2016-7936
#     - CVE-2016-7937
#     - CVE-2016-7938
#     - CVE-2016-7939
#     - CVE-2016-7940
#     - CVE-2016-7973
#     - CVE-2016-7974
#     - CVE-2016-7975
#     - CVE-2016-7983
#     - CVE-2016-7984
#     - CVE-2016-7985
#     - CVE-2016-7986
#     - CVE-2016-7992
#     - CVE-2016-7993
#     - CVE-2016-8574
#     - CVE-2016-8575
#     - CVE-2017-5202
#     - CVE-2017-5203
#     - CVE-2017-5204
#     - CVE-2017-5205
#     - CVE-2017-5341
#     - CVE-2017-5342
#     - CVE-2017-5482
#     - CVE-2017-5483
#     - CVE-2017-5484
#     - CVE-2017-5485
#     - CVE-2017-5486
#   4.9.1-r0:
#     - CVE-2017-11108

build() {
	CFLAGS="$CFLAGS -flto=auto" \
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr
	cmake --build build
}

check() {
	cmake --build build --target check
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
69bc52ef7af7fd562370adf2e95cb592aad6193df9ab1708de52ac86a4c1cff72e8b256a739b435c324ee2df61051abde7d2659bc40f061d7c4fbcab1dcaa2e2  tcpdump-4.99.5.tar.gz
"
